package cn.tony.game.super_tank;

import java.awt.Color;
import java.awt.Graphics;

public class BloodStrip extends Drawable {

    private int maxBlood     = 100;

    int         currentBlood = 100;

    public BloodStrip() {
        h = 5;
    }

    public int getCurrentBlood() {
        return currentBlood;
    }

    public void setCurrentBlood(int currentBlood) {
        if (currentBlood < 0 || currentBlood > maxBlood) {
            return;
        }
        this.currentBlood = currentBlood;
    }

    private int getRedW() {
        return (int) Math.round(w * (((double) currentBlood) / (double) maxBlood));
    }

    @Override
    public void draw(Graphics g) {
        g.setColor(Color.white);
        g.fillRect(x, y, w, h);
        g.setColor(Color.red);
        g.fillRect(x, y, getRedW(), h);
    }

}
